/**
 * Created by 魏爷 on 2016/5/19.
 */
$(function(){
    var url=$('#del_url').val();
    var rec_url=$('#rec_url').val();
    var book_url=$('#srceen-url').val();
    var book_url_null=$('#session-null').val();
    var app={
        delect:function(obj){
            var loading=layer.load(1);
            $.post(
                url,
                {book_id:obj.attr('data-id-del')},
                function(res){
                    layer.close(loading);
                    if(res.status==1){
                        layer.msg(res.info,{icon:1});
                        window.location.reload();
                    }else{
                        layer.msg(res.info,{icon:2});
                        window.location.reload();
                    }
                });
        },

        rec:function(obj){
            var loading=layer.load(1);
            $.post(
                rec_url,
                {book_id:obj.attr('data-id-rec')},
                function(res){
                    layer.close(loading);
                    if(res.status==1){
                        layer.msg(res.info,{icon:1});
                        window.location.reload();
                    }else{
                        layer.msg(res.info,{icon:2});
                        window.location.reload();
                    }
                });
        },

        //screen:function(obj){
        //    $.post(
        //        book_url,
        //        {book_id:obj.attr('data-book')},
        //        window.location.reload()
        //       );
        //},

        //sessionnull:function(obj){
        //    $.post(
        //        book_url_null
        //    );
        //},

    }
    $('.del').click(function () {
        app.delect($(this));
    });
    $('.rec').click(function () {
        app.rec($(this));
    });
    $('.srceen').click(function () {
        app.screen($(this));
    });
    //$('.sessionnull').click(function () {
    //    app.sessionnull($(this));
    //})
});
